﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Niusys.WebAPI.Models;
using Niusys.Repostories;
using Niusys.Entities;
using Odn.Dtos;

namespace Niusys.WebAPI.Common.Services
{
    public interface IProductService
    {
        Page<Product> GetProductList();
        Product GetProduct(Guid productId);
        Guid AddProduct(Product product);
        void UpdateProduct(Product product);
        void DeleteProduct(Guid productId);
    }

    public class ProductService : IProductService
    {
        private readonly IProductRepository _productRepository;

        public ProductService(IProductRepository productRepository)
        {
            this._productRepository = productRepository;
        }
        public Guid AddProduct(Product product)
        {
            return _productRepository.AddProduct(product);
        }

        public void DeleteProduct(Guid productId)
        {
            _productRepository.DeleteProduct(productId);
        }

        public Product GetProduct(Guid productId)
        {
            return _productRepository.GetProduct(productId);
        }

        public Page<Product> GetProductList()
        {
            return _productRepository.GetProductList();
        }

        public void UpdateProduct(Product product)
        {
            _productRepository.UpdateProduct(product);
        }
    }
}